package com.panshi.controller;

import com.panshi.service.DetailService;
import com.panshi.vo.ArticleOkVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Controller
@RequestMapping("zx")
public class DetailController{
    @Autowired
    DetailService detailService;

    @CrossOrigin(origins = "*",maxAge = 3600)
    @GetMapping("/detail/{id}")
    @ResponseBody
    public ArticleOkVO getArticleOkVO(@PathVariable(value = "id") Integer id) {
        detailService.insertReadSum(id);
        return detailService.getArticleOkVO(id);
    }

    //其他看点
    @CrossOrigin(origins = "*",maxAge = 3600)
    @GetMapping("/detail/other/{sort}")
    @ResponseBody
    public List<ArticleOkVO> listOtherArticleOkVOs(@PathVariable(value = "sort") Integer sort) {
        return detailService.listDetailOtherArticleOkVOs(sort);
    }
}